package common;
import ConnDatabase.*;
import java.sql.* ;
import java.util.* ;

public class SelectList  {
	
	private String firstCode ;
	private String firstValue ;
	private HashMap hmap ;
	public SelectList() {
	}
	public void getList(String searchStr,String code,String value) {
		firstCode = "" ;
		firstValue = "" ;
		ConnDatabase conn = new ConnDatabase() ;
		try {
			ResultSet rs = conn.executeQuery(searchStr) ;
			hmap = new HashMap() ;
			int i = 0 ;
			String codeValue ;
			String valueValue ;
			while (rs.next())  {
				i ++ ;
				codeValue = rs.getString(code) ;
				valueValue = rs.getString(value) ;
				if (i == 1) {
					firstCode = codeValue ;
					firstValue = valueValue ;
				}
				hmap.put(codeValue,valueValue) ;	
			}
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}			
		
	}
	
	public String getFirstCode() {
		return firstCode;
	}
	
	public String getFirstValue() {
		return firstValue ;
	}
	
	public String getValue(String code) {
		System.out.println(code) ;
		return (String)hmap.get(code) ;
	}	
	
	public Map getMap() {
		return hmap;	
	}				

}